<?php
class EmployeesDao {
	public $table = 'employees';
	public function get($id){
		return ClassManager::getSql()->onedata($this->table,'*',"where id =".intval($id));
	}
	
	public function getDataPairList($strs_list){
		$strs = implode(',', $strs_list);
		return ClassManager::getSql()->dataPairList($this->table,'id,name'," where id in (".$strs.")");
	}	
	
	public function getListByDepartment($department){
		return ClassManager::getSql()->datalist($this->table,'*',"where department=".$department);
	}
	public function add($data){
		ClassManager::getSql()->insert($this->table, $data);
	}
	public function update($data,$id){
		ClassManager::getSql()->updates($this->table, $data,"where id=".intval($id));
	}
	public function searchList($where=array(),$order='',$limit=0){
		$where = $this->searchWhere($where);
		return ClassManager::getSql()->dataList1($this->table,'*',$where,$order,$limit);
	}
	public function searchNumber($where){
		$where = $this->searchWhere($where);
		$tmp = ClassManager::getSql()->onedata1($this->table,"count(*)  ",$where);
		return $tmp[0];
	}
	public function searchWhere($where){
		$likeWhere = array('name');
		$where1 = array();
			foreach ($where as  $k=>$v){
			if (isset($v)&&$v!==""){
				if (in_array($k,$likeWhere) and !is_array($v)){
					$where1[$k] = array('%'.$v.'%' , 'like');
				}
				else{
					$where1[$k] =  $v;
				}
			}
		}
		unset($where);
		return $where1;
	}
	public function deleteBatchByid($id){
		ClassManager::getSql()->delete($this->table,"where id in(".$id.")");
	}
}

?>